﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8" />
    <title>WashingMachine: WashingMachine.cpp Source File</title>
    <link href="/Content/Help.css" rel="stylesheet" type="text/css" />
    <link href="/Content/css/tabs.css" rel="stylesheet" type="text/css" />
    <link href="/Content/css/doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
    <div id="header">
        <img id="logo" alt="StateForge" src="/Content/Images/StateForgeLogo.png" />
        <div id="title">
            <h1>
                Examples using state machines generated by StateBuilderCpp
            </h1>
            <h3>
                WashingMachine: WashingMachine.cpp Source File
            </h3>
        </div>
        <div id="menucontainer">
            <ul id="menu">
                <li><a href="/">Home</a></li>
                <li><a href="/Home/Download">Downloads</a></li>
                <li><a href="/Help/state-machine-tools.aspx">Help</a></li>
                <li><a href="/Home/Faq">F.A.Q</a></li>
                <li><a href="/Home/About">Contact us</a></li>
            </ul>
        </div>
    </div>
<!-- Generated by Doxygen 1.7.4 -->
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>File&#160;List</span></a></li>
      <li><a href="globals.html"><span>File&#160;Members</span></a></li>
    </ul>
  </div>
<div class="header">
  <div class="headertitle">
<div class="title">WashingMachine.cpp</div>  </div>
</div>
<div class="contents">
<a href="_washing_machine_8cpp.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="preprocessor">#include &lt;stdexcept&gt;</span>
<a name="l00002"></a>00002 <span class="preprocessor">#include &lt;ObserverStd.h&gt;</span>
<a name="l00003"></a>00003 <span class="preprocessor">#include &quot;<a class="code" href="_washing_machine_8h.html">WashingMachine.h</a>&quot;</span>
<a name="l00004"></a>00004 <span class="preprocessor">#include &quot;WashingMachineFsm.h&quot;</span>
<a name="l00005"></a>00005 <span class="preprocessor">#include &lt;iostream&gt;</span>
<a name="l00006"></a>00006 
<a name="l00007"></a>00007 <span class="keyword">using namespace </span>std;
<a name="l00008"></a>00008 
<a name="l00009"></a><a class="code" href="class_washing_machine.html#ab1761ae76138d2a5b729977bc0e9fc93">00009</a> <a class="code" href="class_washing_machine.html#ab1761ae76138d2a5b729977bc0e9fc93">WashingMachine::WashingMachine</a>()
<a name="l00010"></a>00010 {
<a name="l00011"></a>00011     m_pContext = <span class="keyword">new</span> WashingMachineContext(*<span class="keyword">this</span>);
<a name="l00012"></a>00012     m_pContext-&gt;SetObserver(fsm::ObserverStd::GetInstance());
<a name="l00013"></a>00013     m_pContext-&gt;EnterInitialState();
<a name="l00014"></a>00014 }
<a name="l00015"></a>00015 
<a name="l00016"></a><a class="code" href="class_washing_machine.html#a39eba5eb4c900c2e5de2ff5f9b0458f2">00016</a> <a class="code" href="class_washing_machine.html#a39eba5eb4c900c2e5de2ff5f9b0458f2">WashingMachine::~WashingMachine</a>()
<a name="l00017"></a>00017 {
<a name="l00018"></a>00018     <span class="keyword">delete</span> m_pContext;
<a name="l00019"></a>00019 }
<a name="l00020"></a>00020 
<a name="l00021"></a><a class="code" href="class_washing_machine.html#a8359ff8fd49442b689789f855238da18">00021</a> WashingMachineContext&amp; <a class="code" href="class_washing_machine.html#a8359ff8fd49442b689789f855238da18">WashingMachine::GetContext</a>()
<a name="l00022"></a>00022 {
<a name="l00023"></a>00023     <span class="keywordflow">if</span>(m_pContext != NULL){
<a name="l00024"></a>00024         <span class="keywordflow">return</span> *m_pContext;
<a name="l00025"></a>00025     } <span class="keywordflow">else</span> {
<a name="l00026"></a>00026         <span class="keywordflow">throw</span> std::runtime_error(<span class="stringliteral">&quot;context is not set&quot;</span>);
<a name="l00027"></a>00027     }
<a name="l00028"></a>00028 }
<a name="l00029"></a>00029 
<a name="l00030"></a><a class="code" href="class_washing_machine.html#abc3bd70a1feba9129c808baad9a418a1">00030</a> <span class="keywordtype">void</span> <a class="code" href="class_washing_machine.html#abc3bd70a1feba9129c808baad9a418a1">WashingMachine::Start</a>()
<a name="l00031"></a>00031 {
<a name="l00032"></a>00032     GetContext().Start();
<a name="l00033"></a>00033 }
<a name="l00034"></a>00034 
<a name="l00035"></a><a class="code" href="class_washing_machine.html#af6813e10ac1576e0b80ea5b2fc7c9144">00035</a> <span class="keywordtype">void</span> <a class="code" href="class_washing_machine.html#af6813e10ac1576e0b80ea5b2fc7c9144">WashingMachine::WashingDone</a>()
<a name="l00036"></a>00036 {
<a name="l00037"></a>00037     GetContext().WashingDone();
<a name="l00038"></a>00038 }
<a name="l00039"></a>00039 
<a name="l00040"></a><a class="code" href="class_washing_machine.html#a1161edc0001019f90502548e8a5e6ed7">00040</a> <span class="keywordtype">void</span> <a class="code" href="class_washing_machine.html#a1161edc0001019f90502548e8a5e6ed7">WashingMachine::RinsingDone</a>()
<a name="l00041"></a>00041 {
<a name="l00042"></a>00042     GetContext().RinsingDone();
<a name="l00043"></a>00043 }
<a name="l00044"></a>00044 
<a name="l00045"></a><a class="code" href="class_washing_machine.html#a39d7190eba16b68129da1d55cfa26761">00045</a> <span class="keywordtype">void</span> <a class="code" href="class_washing_machine.html#a39d7190eba16b68129da1d55cfa26761">WashingMachine::SpinningDone</a>()
<a name="l00046"></a>00046 {
<a name="l00047"></a>00047     GetContext().SpinningDone();
<a name="l00048"></a>00048 }
<a name="l00049"></a>00049 
<a name="l00050"></a><a class="code" href="class_washing_machine.html#a3fe9b3be5290f450adf539f869a2e9cd">00050</a> <span class="keywordtype">void</span> <a class="code" href="class_washing_machine.html#a3fe9b3be5290f450adf539f869a2e9cd">WashingMachine::Fault</a>()
<a name="l00051"></a>00051 {
<a name="l00052"></a>00052     GetContext().Fault();
<a name="l00053"></a>00053 }
<a name="l00054"></a>00054 
<a name="l00055"></a><a class="code" href="class_washing_machine.html#a7d3c6ac1bda9c64066591e5c2330b076">00055</a> <span class="keywordtype">void</span> <a class="code" href="class_washing_machine.html#a7d3c6ac1bda9c64066591e5c2330b076">WashingMachine::DiagnoseSuccess</a>()
<a name="l00056"></a>00056 {
<a name="l00057"></a>00057     GetContext().DiagnoseSuccess();
<a name="l00058"></a>00058 }
<a name="l00059"></a>00059 
<a name="l00060"></a><a class="code" href="class_washing_machine.html#acf07f915a9f72597e99bd29708da4a96">00060</a> <span class="keywordtype">void</span> <a class="code" href="class_washing_machine.html#acf07f915a9f72597e99bd29708da4a96">WashingMachine::Print</a>(<span class="keyword">const</span> <span class="keywordtype">string</span>&amp; message)
<a name="l00061"></a>00061 {
<a name="l00062"></a>00062     cout &lt;&lt; message &lt;&lt; endl;
<a name="l00063"></a>00063 }
</pre></div></div>
</div>
﻿<div id="footer">
    <hr />
    <p>
        Copyright &copy; 2011 StateForge.</p>
    <hr />
</div>
</body> </html> 
